<%@ page import="static com.test.ws.s1.utils.Res.fileUrl" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户管理</title>
    <style>
        /* 基础表格样式 */
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        th, td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: center;
        }
        th {
            background-color: #4CAF50;
            color: white;
            font-weight: bold;
        }
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #e9e9e9;
        }

        /* 头像样式 */
        .avatar-circle {
            border-radius: 50%;
            width: 50px;
            height: 50px;
            object-fit: cover;
            border: 2px solid #ddd;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: transform 0.3s;
        }
        .avatar-circle:hover {
            transform: scale(1.1);
        }

        /* 搜索栏样式 */
        .search-bar {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            margin: 20px 0;
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            align-items: center;
        }
        .search-input {
            flex: 1;
            min-width: 200px;
            border: 2px solid #dee2e6;
            border-radius: 25px;
            padding: 10px 20px;
            font-size: 14px;
            transition: all 0.3s;
        }
        .search-input:focus {
            border-color: #4CAF50;
            box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
        }
        .search-btn {
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 25px;
            padding: 10px 25px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s;
        }
        .search-btn:hover {
            background-color: #45a049;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .reset-btn {
            background-color: #f44336;
            color: white;
            border: none;
            border-radius: 25px;
            padding: 10px 25px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s;
            text-decoration: none;
            display: inline-block;
        }
        .reset-btn:hover {
            background-color: #d32f2f;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }

        /* 操作按钮 */
        .action-btn {
            padding: 6px 12px;
            margin: 0 5px;
            border-radius: 4px;
            text-decoration: none;
            color: white;
            font-size: 14px;
            transition: all 0.3s;
        }
        .edit-btn {
            background-color: #2196F3;
        }
        .edit-btn:hover {
            background-color: #0b7dda;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .delete-btn {
            background-color: #f44336;
        }
        .delete-btn:hover {
            background-color: #d32f2f;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .add-btn {
            display: inline-block;
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border-radius: 4px;
            text-decoration: none;
            margin-top: 20px;
            transition: all 0.3s;
        }
        .add-btn:hover {
            background-color: #45a049;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }

        /* 分页样式 */
        .pagination-container {
            margin: 30px 0;
            display: flex;
            justify-content: center;
        }
        .pagination {
            display: flex;
            gap: 5px;
            list-style: none;
            padding: 0;
        }
        .page-item {
            margin: 0;
        }
        .page-link {
            padding: 8px 16px;
            border: 1px solid #ddd;
            border-radius: 4px;
            color: #4CAF50;
            text-decoration: none;
            transition: all 0.3s;
        }
        .page-item.active .page-link {
            background: #4CAF50;
            color: white;
            border-color: #4CAF50;
        }
        .page-link:hover:not(.active) {
            background: #f1f1f1;
        }
        .page-item.disabled .page-link {
            color: #ccc;
            pointer-events: none;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            table, thead, tbody, th, td, tr {
                display: block;
            }
            thead tr {
                position: absolute;
                top: -9999px;
                left: -9999px;
            }
            tr {
                margin-bottom: 15px;
                border: 1px solid #ddd;
                border-radius: 5px;
            }
            td {
                border: none;
                border-bottom: 1px solid #eee;
                position: relative;
                padding-left: 50%;
                text-align: right;
            }
            td:before {
                content: attr(data-label);
                position: absolute;
                left: 10px;
                width: 45%;
                padding-right: 10px;
                font-weight: bold;
                text-align: left;
            }
            .search-bar {
                flex-direction: column;
                align-items: stretch;
            }
            .search-input, .search-btn, .reset-btn {
                width: 100%;
                margin-bottom: 10px;
            }
        }


        /*分页*/
        .pagination {
            display: flex;
            gap: 8px;
            padding: 15px 0;
        }

        .pagination a {
            padding: 8px 16px;
            border: 1px solid #4CAF50;
            border-radius: 4px;
            text-decoration: none;
            color: #4CAF50;
            transition: all 0.3s;
        }

        .pagination a.current {
            background: #4CAF50;
            color: white;
            border-color: #4CAF50;
        }

        .pagination a:hover:not(.current) {
            background: #f1f1f1;
        }
    </style>
</head>
<body>
<h2 style="color: #4CAF50; text-align: center; margin-top: 20px;">附图管理列表</h2>

<!-- 搜索栏 -->
<div class="search-bar">
    <form action="${pageContext.request.contextPath}/imgsCha" method="get">
        <input type="text" class="search-input" name="user_name" placeholder="输入线路名称" value="${param.route.route_name}">
        <button type="submit" class="search-btn">搜索</button>
        <a href="${pageContext.request.contextPath}/imgsCha" class="reset-btn">重置</a>
    </form>
</div>

<!-- 用户表格 -->
<table>
    <thead>
    <tr>
        <th>编号</th>
        <th>线路名称</th>
        <th>状态</th>
        <th>是否轮播</th>
        <th>附图</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="user" items="${imgsList}">
        <tr>
            <td data-label="编号">${user.imgs_id}</td>
            <td data-label="线路名称">${user.route.route_name}</td>
            <td data-label="是否轮播">${user.imgs_lbzt}</td>
            <td data-label="状态">${user.imgs_zt}</td>
            <td data-label="附图">
                <img src="<%=fileUrl%>${user.imgs_dz}" class="avatar-circle" alt="${user.imgs_dz}的头像">
            </td>
            <td data-label="操作">
                <a href="${pageContext.request.contextPath}/imgsGai?id=${user.imgs_id}" class="action-btn edit-btn">编辑</a>
                <a href="${pageContext.request.contextPath}/imgsDel?id=${user.imgs_id}"
                   class="action-btn delete-btn"
                   onclick="return confirm('确认删除用户 ${user.imgs_dz} 吗？')">删除</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<!-- 添加用户按钮 -->

<div class="pagination">
    <c:if test="${pageInfo.hasPreviousPage}">
        <a href="imgsCha?pageNum=1&user_name=${param.route.route_name}">首页</a>
        <a href="imgsCha?pageNum=${pageInfo.pageNum-1}&user_name=${param.route.route_name}">上一页</a>
    </c:if>

    <c:forEach begin="1" end="${pageInfo.pages}" var="pn">
        <a href="imgsCha?pageNum=${pn}&username=${param.route.route_name}"
           <c:if test="${pn == pageInfo.pageNum}">class="current"</c:if>
        >${pn}</a>
    </c:forEach>

    <c:if test="${pageInfo.hasNextPage}">
        <a href="imgsCha?pageNum=${pageInfo.pageNum+1}&username=${param.route.route_name}">下一页</a>
        <a href="imgsCha?pageNum=${pageInfo.pages}&username=${param.route.route_name}">末页</a>
    </c:if>
</div>



</body>
</html>